package com.util;

import java.io.IOException;
import java.io.OutputStream;
import java.util.List;

import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import com.bean.Room;



public class Export {
	   
    //建立学生表格  
    public void buildBaojiaExcel(List list, String sheetname, OutputStream out) {  
                  
        HSSFWorkbook wb = new HSSFWorkbook();  
        HSSFSheet sheet1 = wb.createSheet("sheet1");  
        HSSFRow row = sheet1.createRow((short) 0);  
        row.createCell(0).setCellValue("ID");  
        row.createCell(1).setCellValue("房间");  
        row.createCell(2).setCellValue("套内面积");  
        row.createCell(3).setCellValue("建筑面积单价");  
        row.createCell(4).setCellValue("标准总价"); 
       
  
          
        for (int i = 0; i < list.size(); i++) {  
            Room s = (Room)list.get(i);  
            row=sheet1.createRow((short)(i+1));  
            row.createCell(0).setCellValue(s.getId());  
            row.createCell(1).setCellValue(s.getRoomnumber());  
            row.createCell(2).setCellValue(s.getArea());  
            row.createCell(3).setCellValue(s.getRoomprice());  
            row.createCell(4).setCellValue(s.getRoomtotal());
            
        }  
        try {  
            out.flush();  
            wb.write(out);  
            out.close();          
  
        } catch (IOException e) {  
            e.printStackTrace();  
            System.out.println("Out  is  closed ");  
        }  
    }
}
